/**
 * 
 */
package travibot;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import travibot.engine.GameSessionFacade;
import travibot.engine.Session;
import travibot.engine.UserProfile;
import travibot.resource.ResourceHelper;
import travibot.ui.UIFactory;


/**
 * @author tajzivit
 *
 */
public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {

        String baseURL = ResourceHelper.getKeyValue("default_profile", "default.profile.base_url");
        String name = ResourceHelper.getKeyValue("default_profile", "default.profile.name");
        String password = ResourceHelper.getKeyValue("default_profile", "default.profile.password");
        
        UserProfile profile = new UserProfile();
        profile.setBaseURL(baseURL);
        profile.setUserName(name);
        profile.setPassword(password);
        
        ClassPathXmlApplicationContext ctx =
 		   new ClassPathXmlApplicationContext("applicationContext.xml");
        
        GameSessionFacade facade = (GameSessionFacade) ctx.getBean("GameSession");        
        
        Session session = facade.getSession(name, profile);        
        session.connect();        
        //Collection<Village> villages = session.getVillages();
        
        UIFactory uiFactory = UIFactory.getFactory(session);   
        uiFactory.setGameSession(facade);
        uiFactory.startUI();
        session.disconnect();
    }
}
